import Vue from 'vue'
import { SUBJECT_TYPE } from '@/config/enum'
import axios from '../utils/axios'
import ViewUI from 'view-design';
Vue.use(ViewUI);

export default Vue.mixin({
    data() {
        return {
            SUBJECT_TYPE
        }
    },
    filters: {
        fmtSubjectType(val) {
            return ['单选题', '多选题', '判断题', '简答题'][val]
        },
        fmtOrder2ABC(val) {
            return 'ABCDEFGHIJKLMNOPQRST' [val]
        },
        fmtOrder2CN(val) {
            return '零一二三四五六七八九十' [val]
        }
    },
    methods: {
        checkArrayHasVal(arr) {
            return arr && arr.length
        },
        checkIsXZT(type) {
            return type === this.SUBJECT_TYPE.DANXUAN || type === this.SUBJECT_TYPE.DUOXUAN
        },
        checkIsNotJDT(type) {
            return type !== this.SUBJECT_TYPE.JIANDA
        },
        async $get(url, params) {
            let { data } = await axios.get(url, { params })
            return data
        },
        async $post(url, params) {
            let { data } = await axios.post(url, params)
            return data
        },
        // 封装message方法
        $ms(msg) {
            this.$Message.success(msg)
        },
        $mw(msg) {
            this.$Message.warning(msg)
        },
        $me(msg) {
            this.$Message.error(msg)
        }
    },
})